package troopmanager.mooresr.us;


public class VehicleDriver implements Comparable<VehicleDriver> {
	private Integer personId;
	private Integer vehicleId;
	private String firstName;
	private String lastName;
	private String make;
	private String model;
	private Integer year;
	private String ownerFirstName;
	private String ownerLastName;
	private Integer seatbelts;
	
	public VehicleDriver() {
		
	}
	

	public VehicleDriver(Person driver, Vehicle vehicle) {
		personId=driver.getPersonId();
		vehicleId=vehicle.getVehicleId();
		firstName=driver.getFirstName();
		lastName=driver.getLastName();
		make=vehicle.getMake();
		model=vehicle.getModel();
		year=vehicle.getYear();
		ownerFirstName=vehicle.getOwnerFirstName();
		ownerLastName=vehicle.getOwnerLastName();
		seatbelts=vehicle.getSeatbelts();
	}

	
	public Integer getPersonId() {
		return personId;
	}

	public Integer getVehicleId() {
		return vehicleId;
	}
	
	public Integer getSeatbelts() {
		return seatbelts;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public String getMake() {
		return make;
	}


	public void setMake(String make) {
		this.make = make;
	}


	public String getModel() {
		return model;
	}


	public void setModel(String model) {
		this.model = model;
	}


	public Integer getYear() {
		return year;
	}


	public void setYear(Integer year) {
		this.year = year;
	}


	public String getOwnerFirstName() {
		return ownerFirstName;
	}


	public void setOwnerFirstName(String ownerFirstName) {
		this.ownerFirstName = ownerFirstName;
	}


	public String getOwnerLastName() {
		return ownerLastName;
	}


	public void setOwnerLastName(String ownerLastName) {
		this.ownerLastName = ownerLastName;
	}


	public void setPersonId(Integer personId) {
		this.personId = personId;
	}


	public void setVehicleId(Integer vehicleId) {
		this.vehicleId = vehicleId;
	}


	public void setSeatbelts(Integer seatbelts) {
		this.seatbelts = seatbelts;
	}


	public String toString() {
		if (firstName.equals(ownerFirstName) && lastName.equals(ownerLastName)) {
			return firstName + " " + lastName + " driving " + make + " " + model + " (" + seatbelts + " seats)";
		} else {
			return firstName + " " + lastName + " driving " + ownerFirstName + " " + ownerLastName + "'s " + make + " " + model + " (" + seatbelts + " seats)";
		}
	}

	@Override
	public int compareTo(VehicleDriver o) {
		// Vehicles are sorted by name
		String fullName = lastName+firstName;
		
		return fullName.compareTo(o.getLastName()+o.getFirstName());
	}
	

}
